﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AcademicPlanner.Framework.Helpers
{
	/// <summary>
	/// WidgetHelper provides static helper methods for creating common
	/// html widgets.
	/// </summary>
	/// <version>1.0</version>
	/// <since>1.0</since>
	public static class WidgetHelper
	{
		/// <summary>
		/// Creates a html message block of a status message indicating success of an action.
		/// </summary>
		/// <param name="pMsg">The status message.</param>
		/// <returns>The html string.</returns>
		/// <seealso cref="M:MessageBlock"/>
		/// <version>1.0</version>
		/// <since>1.0</since>
		public static string SuccessMessageBlock(string pMsg)
		{
			return MessageBlock("success", pMsg);
		}

		/// <summary>
		/// Creates a html message block of a status message calling attention 
		/// about the execution of an action.
		/// </summary>
		/// <param name="pMsg">The status message.</param>
		/// <returns>The html string.</returns>
		/// <version>1.0</version>
		/// <since>1.0</since>
		public static string InfoMessageBlock(string pMsg)
		{
			return MessageBlock("info", pMsg);
		}

		/// <summary>
		/// Creates a html message block.
		/// </summary>
		/// <param name="pClass">The css class of the message block.</param>
		/// <param name="pMsg">The message.</param>
		/// <returns>The html string.</returns>
		/// <version>1.0</version>
		/// <since>1.0</since>
		public static string MessageBlock(string pClass, string pMsg)
		{
			string vTpl = "<div class=\"message {0}\">{1}</div>";
			return string.Format(vTpl, pClass, pMsg);
		}

		/// <summary>
		/// Creates a html block for input errors.
		/// </summary>
		/// <param name="pContent">The content of the block i.e. the input errors.</param>
		/// <param name="pId">The html id of the block.</param>
		/// <param name="pClass">The extra css class of the block.</param>
		/// <returns>The html for the input errors block.</returns>
		/// <version>1.0</version>
		/// <since>1.0</since>
		public static string FormErrorsBlock(string pContent, string pId, string pClass)
		{
			string vTpl = "<div id=\"{0}\" class=\"errors-summary {1}\">{2}</div>";
			return string.Format(vTpl, pId, pClass, pContent);
		}
	}
}
